Imports System.Windows.Forms
Imports dao
 Imports System.Data
Imports DTO
Public Class DIEMBus
Inherits AbstractBus
 Public Sub New()
 End Sub
 Public Sub New(ByVal ConnectionString As KetNoiDto)
 ketnoi = ConnectionString
 End Sub
 #Region "Xử Lý" 
 Public Sub Them(ByVal Dto As DIEMDto)
 Dim Dao As New DIEMDao(ketnoi)
 Dao.Them(Dto)
 End Sub
 Public Sub Xoa( ByVal IDDIEM As System.Int32)
 Dim Dao As New DIEMDao(ketnoi)
 Dao.xoa(IDDIEM)
 End Sub
 Public Sub sua(ByVal Dto As DIEMDto)
 Dim Dao As New DIEMDao(ketnoi)
 Dao.sua(Dto)
 End Sub
 #End Region 
 Public Function LayBangTable() As DataTable
 Dim Dao As New DIEMDao(ketnoi)
 dao.laybang()
 Return Dao
 End Function
 Public Function LayBangTableIlist() As IList
 Dim Dao As New DIEMDao(ketnoi)
 Dim aList As New ArrayList 
 For i As Integer = 0 To Dao.Rows.Count - 1 
 Dim dtoDIEM As DIEMdto = LayBangDTo(i, Dao) 
 aList.Add(dtoDIEM)
 Next 
 Return aList 
 End Function
 Public Function LayBangTableSQL(ByVal sql As string) As DataTable
 Dim Dao As New  AbstractDao(sql,sql,ketnoi)
 Return Dao
 End Function
 Public Sub suaIDMON( ByVal IDMON as System.Int32, ByVal IDDIEM As System.Int32 )
 Dim dao As New DIEMDao(ketnoi)
 dao.suaIDMON(IDMON,IDDIEM)
 End Sub 
 Public Sub suaIDHOCSINH( ByVal IDHOCSINH as System.Int32, ByVal IDDIEM As System.Int32 )
 Dim dao As New DIEMDao(ketnoi)
 dao.suaIDHOCSINH(IDHOCSINH,IDDIEM)
 End Sub 
 Public Sub suaTONGDIEM( ByVal TONGDIEM as System.Int32, ByVal IDDIEM As System.Int32 )
 Dim dao As New DIEMDao(ketnoi)
 dao.suaTONGDIEM(TONGDIEM,IDDIEM)
 End Sub 
 Public Sub suaTRANGTHAI( ByVal TRANGTHAI as System.Int32, ByVal IDDIEM As System.Int32 )
 Dim dao As New DIEMDao(ketnoi)
 dao.suaTRANGTHAI(TRANGTHAI,IDDIEM)
 End Sub 
 Public Sub suaGHICHU( ByVal GHICHU as System.Int32, ByVal IDDIEM As System.Int32 )
 Dim dao As New DIEMDao(ketnoi)
 dao.suaGHICHU(GHICHU,IDDIEM)
 End Sub 
 Public Function LayBangTable( ByVal IDDIEM As System.Int32) As DataTable
 Dim Dao As New DIEMDao(IDDIEM,ketnoi)
 Return Dao
 End Function
 Public Function LayBangTableIlist( ByVal IDDIEM As System.Int32) As IList
 Dim Dao As New DIEMDao(IDDIEM,ketnoi)
 Dim aList As New ArrayList 
 For i As Integer = 0 To Dao.Rows.Count - 1 
 Dim dtoDIEM As DIEMdto = LayBangDTo(i, Dao) 
 aList.Add(dtoDIEM)
 Next 
 Return aList 
 End Function
 Public Function LayBangTableTheoIDDIEM (ByVal IDDIEM As System.Int32) As DataTable
 Dim Dao As New DIEMDao(ketnoi)
 Dao.layBangTheoIDDIEM(IDDIEM)
 Return Dao
 End Function
 Public Function LayBangTableTheoIDDIEM (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New DIEMDao(ketnoi)
 Dao.layBangTheoIDDIEM(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoIDDIEM (ByVal IDDIEM As System.Int32) 
 Dim Dao As New DIEMDao(ketnoi)
 Dao.XOABangTheoIDDIEM(IDDIEM)
 End sub
 Public Function LayBangTableTheoIDMON (ByVal IDMON As System.Int32) As DataTable
 Dim Dao As New DIEMDao(ketnoi)
 Dao.layBangTheoIDMON(IDMON)
 Return Dao
 End Function
 Public Function LayBangTableTheoIDMON (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New DIEMDao(ketnoi)
 Dao.layBangTheoIDMON(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoIDMON (ByVal IDMON As System.Int32) 
 Dim Dao As New DIEMDao(ketnoi)
 Dao.XOABangTheoIDMON(IDMON)
 End sub
 Public Function LayBangTableTheoIDHOCSINH (ByVal IDHOCSINH As System.Int32) As DataTable
 Dim Dao As New DIEMDao(ketnoi)
 Dao.layBangTheoIDHOCSINH(IDHOCSINH)
 Return Dao
 End Function
 Public Function LayBangTableTheoIDHOCSINH (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New DIEMDao(ketnoi)
 Dao.layBangTheoIDHOCSINH(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoIDHOCSINH (ByVal IDHOCSINH As System.Int32) 
 Dim Dao As New DIEMDao(ketnoi)
 Dao.XOABangTheoIDHOCSINH(IDHOCSINH)
 End sub
 Public Function LayBangTableTheoTONGDIEM (ByVal TONGDIEM As System.Int32) As DataTable
 Dim Dao As New DIEMDao(ketnoi)
 Dao.layBangTheoTONGDIEM(TONGDIEM)
 Return Dao
 End Function
 Public Function LayBangTableTheoTONGDIEM (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New DIEMDao(ketnoi)
 Dao.layBangTheoTONGDIEM(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoTONGDIEM (ByVal TONGDIEM As System.Int32) 
 Dim Dao As New DIEMDao(ketnoi)
 Dao.XOABangTheoTONGDIEM(TONGDIEM)
 End sub
 Public Function LayBangTableTheoTRANGTHAI (ByVal TRANGTHAI As System.Int32) As DataTable
 Dim Dao As New DIEMDao(ketnoi)
 Dao.layBangTheoTRANGTHAI(TRANGTHAI)
 Return Dao
 End Function
 Public Function LayBangTableTheoTRANGTHAI (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New DIEMDao(ketnoi)
 Dao.layBangTheoTRANGTHAI(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoTRANGTHAI (ByVal TRANGTHAI As System.Int32) 
 Dim Dao As New DIEMDao(ketnoi)
 Dao.XOABangTheoTRANGTHAI(TRANGTHAI)
 End sub
 Public Function LayBangTableTheoGHICHU (ByVal GHICHU As System.Int32) As DataTable
 Dim Dao As New DIEMDao(ketnoi)
 Dao.layBangTheoGHICHU(GHICHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoGHICHU (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New DIEMDao(ketnoi)
 Dao.layBangTheoGHICHU(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoGHICHU (ByVal GHICHU As System.Int32) 
 Dim Dao As New DIEMDao(ketnoi)
 Dao.XOABangTheoGHICHU(GHICHU)
 End sub
 Public Function LayBangDTo( ByVal IDDIEM As System.Int32) As DIEMdto
 Dim Dao As New DIEMDao(IDDIEM, ketnoi)
 Dim dto As New DIEMdto
 If Dao.Rows.Count<= 0 then Return dto
 Try
 If IsDBNull(Dao.Rows(0)("IDDIEM")) = False Then
 Dto.IDDIEM = Dao.Rows(0)("IDDIEM")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("DIEM.IDDIEM")) = False Then
 Dto.IDDIEM = Dao.Rows(0)("DIEM.IDDIEM")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("IDMON")) = False Then
 Dto.IDMON = Dao.Rows(0)("IDMON")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("DIEM.IDMON")) = False Then
 Dto.IDMON = Dao.Rows(0)("DIEM.IDMON")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("IDHOCSINH")) = False Then
 Dto.IDHOCSINH = Dao.Rows(0)("IDHOCSINH")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("DIEM.IDHOCSINH")) = False Then
 Dto.IDHOCSINH = Dao.Rows(0)("DIEM.IDHOCSINH")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("TONGDIEM")) = False Then
 Dto.TONGDIEM = Dao.Rows(0)("TONGDIEM")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("DIEM.TONGDIEM")) = False Then
 Dto.TONGDIEM = Dao.Rows(0)("DIEM.TONGDIEM")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(0)("TRANGTHAI")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("DIEM.TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(0)("DIEM.TRANGTHAI")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(0)("GHICHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("DIEM.GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(0)("DIEM.GHICHU")
 End if
Catch ex As Exception
End Try
 Return dto
 end function
 Public Function LayBangDTo(ByVal i As Integer, ByVal dao As DataTable) As DIEMdto
 Dim dto As New DIEMdto
 If Dao.Rows.Count<=0 then Return dto
 Try
 If IsDBNull(Dao.Rows(i)("IDDIEM")) = False Then
 Dto.IDDIEM = Dao.Rows(i)("IDDIEM")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("DIEM.IDDIEM")) = False Then
 Dto.IDDIEM = Dao.Rows(i)("DIEM.IDDIEM")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("IDMON")) = False Then
 Dto.IDMON = Dao.Rows(i)("IDMON")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("DIEM.IDMON")) = False Then
 Dto.IDMON = Dao.Rows(i)("DIEM.IDMON")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("IDHOCSINH")) = False Then
 Dto.IDHOCSINH = Dao.Rows(i)("IDHOCSINH")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("DIEM.IDHOCSINH")) = False Then
 Dto.IDHOCSINH = Dao.Rows(i)("DIEM.IDHOCSINH")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("TONGDIEM")) = False Then
 Dto.TONGDIEM = Dao.Rows(i)("TONGDIEM")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("DIEM.TONGDIEM")) = False Then
 Dto.TONGDIEM = Dao.Rows(i)("DIEM.TONGDIEM")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(i)("TRANGTHAI")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("DIEM.TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(i)("DIEM.TRANGTHAI")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(i)("GHICHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("DIEM.GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(i)("DIEM.GHICHU")
 End if
 Catch ex As Exception
 End Try
 Return dto
 end function
 Public Function LayBangDTo(ByVal dong As Integer, ByVal dao As DataGridView) As DIEMdto
 Dim dto As New DIEMdto
 If dao.Rows.Count <= 0 Then Return dto
 For cot As Integer = 0 To dao.Columns.Count - 1
 Try
 Dto.HoTro(dao.Columns(cot).DataPropertyName, dao.Item(cot, dong).Value)
 Catch ex As Exception
 End Try
 Next
 Return Dto
 End Function
 Public Function layBangNhieuTable() as Datatable
 Dim Dao As New DIEMDao(ketnoi)
 Dao.layBangNhieuTable()
 Return Dao
 End Function
 Public Sub Taotable()
 Dim Dao As New DIEMDao(ketnoi)
 Dao.TaoTable()
 End Sub
 End Class

